
#ifndef __BITTREEITER__
#define __BITTREEITER__
typedef     struct BitTreeiter_t*    TreeIter;

typedef     struct BitTree_t         Tree;
/*Compare function for Binary tree.
Returns:
True if (_data1 < _data2), and false otherwise.*/
typedef     int (* Less) (void* _data1, void* _data2);

/*Container of Binary Tree.
 On creation  function of "Less" type has to be supplyed.*/
Tree* TreeNew(Less _less);

/*Insert operates at perfomance at O(log(n))*/
TreeIter   TreeInsert(Tree* _this,void* _data);

/*Find operates at perfomance O(log(n))*/
/*If element not found returns End */
TreeIter   TreeFind(Tree*,void*);

/*Boolian function. Return, true if TreeEmpty*/
int   TreeIsEmpty(Tree*);

/*Boolian function. Returns, true if iterators are equal*/
int TreeIsEqual(TreeIter iter1,TreeIter iter2);

/*Deallocate all nodes and Tree struct. Performance O(n)*/
void TreeDeleteTree(Tree* _this);

/*Next and Prev operates with performance log(n);
Next to Last Valid returns TreeIter End
Prev to Begin       return TreeIter End
*/
TreeIter  TreeNext(TreeIter _iter);
TreeIter  TreePrev(TreeIter _iter);

/*removes Node from tree , and returns iterator to Next.
If supplyed _iter non valid
the behaviour is UNPREDICTED.
Invalidate all iterrators*
If Removes the Last Valid element returns End
If supplyed iterator was TreeIter End returns End*/
TreeIter TreeRemoveNode(Tree*  _this,TreeIter _iter);

/*Returns Data,
UNPREDICTED BEHAVOIR with if sent iterator not valid  */
void* TreeGetData(TreeIter _iter);

/*Using TreeNext commant to End is illigal operation and
TreePrev on Begin is illigal operation*/
TreeIter  TreeEnd(Tree*);
TreeIter  TreeBegin(Tree*);

#endif /* __BITTREEITER__*/
